/*
 *  Borum, Boolean rule manipulator.
 *  Copyright (C) 2009 Jon Lennersten, Johan Hedin, Daniel Rosenberg
 *
 *  This file is part of Borum.
 *
 *  Borum is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Borum is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Borum.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.mawell.borum.demo;

import com.mawell.borum.MultiView;
import com.mawell.borum.OperandProperty;
import com.mawell.borum.Term;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;

public class BorumMultiDemoFrame extends JFrame {

    public BorumMultiDemoFrame() throws HeadlessException {
        init();
        setSize(700, 500);

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        }
        );
        //pack();
    }


    public void init() {
        getContentPane().setLayout(new GridBagLayout());
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setTitle("Borum demo");

        /*RuleModel model = new RuleModel();
        DateTerm term = new DateTerm();
        term.setName("Undersökningsdatum");
        term.setLabelSave("Spara");
        term.setLabelCancel("Avbryt");
        model.getPossibleTerms().add(term);
        term = new DateTerm();
        term.setName("Signeringsdatum");
        term.setLabelSave("Spara");
        term.setLabelCancel("Avbryt");
        model.getPossibleTerms().add(term);
        RuleView rView = new RuleView(model); */

        java.util.List<Term> possibleTerms = new ArrayList<Term>();
        ExaminationDateTerm edt = new ExaminationDateTerm();
        possibleTerms.add(edt);

        java.util.List<OperandProperty> possibleProperties = new ArrayList<OperandProperty>();
        MaxHitsProperty mhp = new MaxHitsProperty();
        possibleProperties.add(mhp);

        MultiView mView = new MultiView(possibleProperties, possibleTerms, new ExampleTranslation(), new ExampleTranslation());       
        mView.setSingleSelection(true);

        GridBagConstraints c = new GridBagConstraints();
        c.anchor = GridBagConstraints.NORTHWEST;
        c.weightx = 1; // add horizontal space to this component
        c.weighty = 1; // add vertical space to this component
        c.gridwidth = 1;
        c.gridheight = 1;
        c.fill = GridBagConstraints.BOTH; // fill vertically and horizontally if bigger than expected

        getContentPane().add(mView, c);
    }

    public static void main(String args[]) throws Exception {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        EventQueue.invokeLater(new Runnable() {
            public void run() {
                new BorumMultiDemoFrame().setVisible(true);
            }
        });


    }

}